package com.命令模式.案例1;

/**
 * 客户端
 */
public class Client {

    public static void main(String[] args) {
        //创建电灯的对象(接收者)
        LightReceiver lightReceiver=new LightReceiver();
        //创建电灯的开关命令
        LightOffComment lightOffComment = new LightOffComment(lightReceiver);
        LightOnComment lightOnComment = new LightOnComment(lightReceiver);
        //需要遥控器来控制
        RemoteController remoteController = new RemoteController();
        //给我们的遥控器设置命令，比如索引为0的是电灯的开关命令
        remoteController.setCommnet(0,lightOnComment,lightOffComment);
        System.out.println("--------------按下电灯开按钮--------------------");
        remoteController.onButtonWasPush(0);
        System.out.println("--------------按下电灯关的按钮------------------");
        remoteController.offButtonWasPush(0);
        System.out.println("--------------电灯撤销按钮--------------------");
        remoteController.undoButtonWasPush();
    }
}
